﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Criterion;
using NHibernate.Linq;
using NHibernate.Transform;
using Thaire.Investment.Domains.Master;

namespace Thaire.Investment.Repository
{
    public class AssetClassRepo : BaseRepository<AssetClass, int>
    {
        public AssetClassRepo(ISession session)
            : base(session)
        {
        }

        //public List<AssetClass> GetOnlyFinancialInstrument()
        //{

        //    object data = _session.QueryOver<AssetClass>().Select(
        //       Projections.Distinct(
        //         Projections.ProjectionList()
        //           .Add(Projections.Property<AssetClass>(x => x.FinancialInstrumentsId))
        //           .Add(Projections.Property<AssetClass>(x => x.FinancialInstrumentsTh))
        //           .Add(Projections.Property<AssetClass>(x => x.FinancialInstrumentsEn))

        //         )
        //     ).List<Object>();
        //    List<Object> obList = new List<object>();
        //    List<AssetClass> result = new List<AssetClass>();
        //    AssetClass asset = new AssetClass();
        //    foreach (var item in obList)
        //    {
        //        object[] dataRow = item as object[];
        //        asset.FinancialInstrumentsId = (int)dataRow[0];
        //        asset.FinancialInstrumentsTh = (String)dataRow[1];
        //        asset.FinancialInstrumentsEn = (String)dataRow[2];
        //        result.Add(asset);
        //    }
        //    return result;
        //}

        //public List<AssetClass> GetAssetTypeByFinancialInstrumentsId(int financialInstrumentsId)
        //{

        //    List<AssetClass> data = _session.QueryOver<AssetClass>().Where(x => x.FinancialInstrumentsId == financialInstrumentsId).List().ToList();

        //    return data;
        //}

        public List<AssetClass> GetListByFinancialInstrumentsReferenceCodeId(int refCodeID)
        {
            return new List<AssetClass>(_session.QueryOver<AssetClass>()
                .Where(x => x.FinancialInstrumentsReferenceCodeID == refCodeID).List());
        }
    }
}

